const mongoose = require('mongoose')
const config = require('config')
const dbUrl=config.get('mongodbUrl')

// 创建mongodb 数据库连接 方法
const connectDB=async ()=>{
    try {
        await mongoose.connect(dbUrl,{
            useNewUrlParser:true,
            useUnifiedTopology:true
        })
        console.log('mongodb connectd.')
    } catch (error) {
        console.log(error.message)
        process.exit(1)
    }
}

module.exports =connectDB